package com.yanq.liancar.adapter;
/*
 *  @创建者     Administrator
 *  @创建时间   2018/11/22  16:52
 *  @描述       ${TODO}
 */


import android.support.annotation.Nullable;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanq.liancar.R;
import com.yanq.liancar.bean.OBDPeiZhiListBean;

import java.util.List;

public class PeijianAdapter extends BaseQuickAdapter<OBDPeiZhiListBean.DataBean._$2Bean, BaseViewHolder> {
    public PeijianAdapter(int layoutResId, @Nullable List<OBDPeiZhiListBean.DataBean._$2Bean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, OBDPeiZhiListBean.DataBean._$2Bean item) {
        helper.setText(R.id.tv_name, item.getName())
                .addOnClickListener(R.id.tv_select)
                .addOnClickListener(R.id.tv_stutas2);
        TextView tv_stutas1 = helper.getView(R.id.tv_stutas1);
        TextView tv_stutas2 = helper.getView(R.id.tv_stutas2);
        TextView tv_select = helper.getView(R.id.tv_select);
        RelativeLayout relativeLayout=helper.getView(R.id.rl_stutas);
        if (item.getStatus()==1){
            relativeLayout.setVisibility(View.VISIBLE);
        }else {
            relativeLayout.setVisibility(View.GONE);
        }
        if (item.getHealthStatus() == 1) {
            tv_stutas1.setTextColor(mContext.getResources().getColor(R.color.green));
            tv_stutas1.setText("正常");
            tv_stutas2.setText("已保养");
            tv_stutas2.setEnabled(false);
        } else {
            tv_stutas1.setTextColor(mContext.getResources().getColor(R.color.red));
            tv_stutas1.setText("已到保养时间");
            tv_stutas2.setText("去保养");
            tv_stutas2.setEnabled(true);
        }

        if (item.getType() == 1) {
            tv_select.setVisibility(View.VISIBLE);
        } else {
            tv_select.setVisibility(View.GONE);
        }

        if (item.getObdPeiZhiDTOs().size()!=0){
            for (int i = 0; i < item.getObdPeiZhiDTOs().size(); i++) {
                if (item.getObdPeiZhiDTOs().get(i).getStatus()==1){
                    tv_select.setText(item.getObdPeiZhiDTOs().get(i).getName());
                }
            }
        }
    }
}
